#!/usr/bin/env python
#coding:utf-8
#Code by Mango
#Created Time: Sat 19 Jul 2014 04:13:37 PM CST

#客户端:用来向服务端发送本机状态消息

import socket
import time
import os
import re
import sys



a = sys.argv[1]
b = sys.argv[2]
#host,port = "115.28.85.175",18000
host,port = a, int(b)

def get_live(host, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host, port))
    s.send("up")
    s.close()
    print "send status to server"

while True:
    get_live(host,port)
    time.sleep(30)  #每30秒向主机报告一次存活
